//@author A0094511L
///@class BOT
///@Description This class is the logic of the BOT program.
///				Bot handles the following operations
///				1. Based on user commands, deceide what command to call from entriesManager class.
///				   These commands are defined in the CommonUtils class. All commands are parsed in, except for help commands.
///				2. Calls Tokeniser to split the user commands into their respective components, for the use by EntriesManager
///				3. Calls Tokeniser to check input format, for format checker of GUI
///				4. Returns Current View of Vector of all Entries to GUI, for display purposes.
///				6. Returns the current count of overdue, today, tasks and events to GUI for GUI to display in sidebar.
///				7. Returns vector of entries for model to use to set data for the use of completer

#ifndef BOTLOGIC_H
#define BOTLOGIC_H

#include <Qtcore>
#include <QDateTime>
#include <string>
#include <QStringList>
#include "Entry.h"
#include "EntryManager.h"
#include "Task.h"
#include "Event.h"
#include "CommonUtils.h"
#include "Tokeniser.h"
#include "EntriesManager.h"

class BotLogic{	

public:

	static BotLogic& getInstance();
	
	//@brief Constructor of Bot Class, updates _allEntries private member by getting current instance.
	BotLogic();
	
	//@brief Destructor, deletes all pointers used in this class
	~BotLogic();

	//@brief This function first extracts the command from the user input by calling tokeniser
	//		 Based on this command, this function executes the command accordingly by either
	//		 1. Call for further extraction using tokeniser's function based on the type of command given
	//		 2. Execute a function from EntriesManager directly.
	//		 Commands that require further extraction will pass in the items extracted as parameters to the respective functions
	//	     for EntriesManager.
	CommonEnum::ReturnStatus executeCommand(string);

	//@brief This function calls on EntriesManager to return the default view required by GUI by calling displayCommand
	//@post  This function returns the default view in the form of a ReturnStatus as defined in CommonUtils
	CommonEnum::ReturnStatus getDefaultView();
	

	//@brief This function is to get all the names of the entries currently stored.
	//@post  This function returns a QStringList of all names of the entries.
	QStringList getAllNames();

	//@brief This function calls EntriesManager to count all the overdue, today, tasks and events.
	//@post  This function returns the number of the above count in the form of an Enum ReturnCount as defined in CommonUtils.
	CommonEnum::ReturnCount getCount();

	//@brief This function checks that the input format is correct by calling tokeniser
	//@post  return true if correct format as defined, false otherwise
	bool checkInputFormat(string);

	//@brief This function calls EntriesManager to return the current's view active vector
	//@post  This function returns the vector of entries of the current view.
	vector<Entry*> getVector();

private:
	
	EntriesManager& _allEntries;
	Tokeniser* _tokeniser;

	CommonEnum::ReturnStatus executeAdd();
	CommonEnum::ReturnStatus executeDelete();
	CommonEnum::ReturnStatus executeSetDone();
	CommonEnum::ReturnStatus executeEdit();
	CommonEnum::ReturnStatus executeDisplay();
	CommonEnum::ReturnStatus executeDisplayAll();
	CommonEnum::ReturnStatus executeSearch();
	CommonEnum::ReturnStatus executeUndo();
	CommonEnum::ReturnStatus executeRedo();
	CommonEnum::ReturnStatus executeDisplayTask();
	CommonEnum::ReturnStatus executeDisplayEvent();
	CommonEnum::ReturnStatus executeDisplayWeek();
	CommonEnum::ReturnStatus executeDisplayDay();
	CommonEnum::ReturnStatus executeDisplayDayBefore();
	CommonEnum::ReturnStatus executeDisplayPastNotDone();
	CommonEnum::ReturnStatus executeClear();
	CommonEnum::ReturnStatus executeDisplayDone();
	CommonEnum::ReturnStatus executeDisplayNotDone();
	CommonEnum::ReturnStatus executeExit();

};

#endif // BOT_H
